package com.tanhua.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tanhua.dubbo.mappers.ReportMapper;
import com.tanhua.model.soul.Report;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@DubboService
public class ReportApiImpl implements ReportApi {
    @Autowired
    private ReportMapper reportMapper;
    @Override
    public void save(Report report) {
        reportMapper.insert(report);
    }

    @Override
    public List<Report> findDimensions(Long id) {
        LambdaQueryWrapper<Report>queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(Report::getUserId,id);
        Report report = reportMapper.selectOne(queryWrapper);
        LambdaQueryWrapper<Report>qw=new LambdaQueryWrapper<>();
        qw.eq(Report::getDimensionsValue,report.getDimensionsValue());
        return reportMapper.selectList(qw);
    }

    @Override
    public Report findByUserId(Long userId) {
        LambdaQueryWrapper<Report>queryWrapper=new LambdaQueryWrapper<>();
        queryWrapper.eq(Report::getUserId,userId);
        return reportMapper.selectOne(queryWrapper);


    }

    @Override
    public Report findById(Long id) {
        return reportMapper.selectById(id);
    }

    @Override
    public void update(Report report) {
        reportMapper.updateById(report);
    }
}
